<template>
  <section>
    <el-select size="mini" v-model="item.contentType" @change="selType" :disabled="!disable">
      <el-option v-for="(type,index) in typeList" :key="index" :value="type.val" :label="type.name"></el-option>
    </el-select>
  </section>
</template>

<script>
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler'
  export default {
    name: "selContentType",
    props:['item','type'],
    data(){
      return {
        typeList:[
          {name:'商品',code:'goods',val:2},
          {name:'活动',code:'activity',val:1}
          ],
        disable:true
      }
    },
    watch:{
    },
    created(){
      if(this.type !== undefined){//如果给type，和type一样
        this.disable=this.type
        this.getTypeList()
      }//没给的话，就用当前的默认
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      getTypeList(){
        if(this.type === 'ad'){
          this.typeList.push({name:'商品搜索页面',code:'page',val:3})
          this.typeList.push({name:'商店',code:'store',val:4})
        }
      },
      selType(e){
        this.$emit('change')
      }
    }
  }
</script>

<style scoped>

</style>
